<template>
  <div class="infomations" id="infomation">
     <Slideshow></Slideshow>
     <div class="content">
         <div class="header">
           <h3>新闻资讯</h3>
           <span class="blues"></span>
           <span class="long"></span>
         </div>
         <div class="news-list">
            <ul>
              <li v-for="(news, index) in newsList" :key="index" @mouseover="wordsColor(index)" @mouseout="wordsColor_1(index)">
                <div class="time">
                  <span class="day">{{news.created_day.day}}</span>
                  <span class="month">{{news.created_day.month}}</span>
                </div>
                <div class="details">
                <h4>
                  <router-link :to="{ name: 'NewsDetails', params: { id: news.id }}" class="title">{{news.title}}</router-link>
                </h4>
                <p>{{news.excerpt}}</p>
                </div>
                <span></span>
              </li>
            </ul>
         </div>
         <div class="block">
           <a href="#infomation">
            <el-pagination
              background
              layout="prev, pager, next"
              :total="total"
              :page-size="pagesize"
              :current-page="currentPage"
              @current-change="handleCurrentChange">
            </el-pagination>
            </a>
         </div>
     </div>
     <Footer></Footer>
     <Fixeds></Fixeds>
     <Dialog></Dialog>
     <!-- <router-view></router-view>    -->
  </div>
</template>
<script>
import Slideshow from '../../common/Slideshow'
import Footer from "../../common/Footer"
import Fixeds from "../../common/Fixeds"
import Dialog from "../../common/Dialog"
export default {
  name: 'Infomation',
  components: {
    Slideshow,
    Footer,
    Fixeds,
    Dialog
  },
  data(){
    return{
      newsList: [],
      currentPage:1,
      pagesize:10,
      total:1
    }
  },
  methods: {
    handleSizeChange: (size) => {
      this.pagesize = size;
    } ,
    handleCurrentChange: function(currentPage){
      this.currentPage = currentPage;
      // document.documentElement.scrollTop = 0,  //点击分页页面返回顶部
        var node = this;
      window.$.get(this.apiUrl + '/articles/index',{
          per_page: 10,
          page:this.currentPage,
          category:1
      }, function (res) {
          node.total = res.meta.pagination.total;
          node.newsList = res.data;
      })
    },
    wordsColor(index){
      let words = document.getElementsByClassName("title")[index];
      words.style.color = '#009ae9';
    },
    wordsColor_1(index){
       let words = document.getElementsByClassName("title")[index];
       words.style.color = '#000';
    }
},
created(){
      this.handleCurrentChange(1);
}
}
</script>
<style scoped>
body,
div,
dl,
dt,
dd,
ul,
ol,
li,
h1,
h2,
h3,
h4,
h5,
h6,
pre,
code,
form,
fieldset,
legend,
input,
button,
textarea,
p,
blockquote,
th,
td {
  overflow: hidden;
}
.infomations{
  width: 100%;
  height: auto;
}
.infomations .content{
  width: 1280px;
  height: auto;
  margin: 50px auto 100px;
}
.infomations .content .header{
  width: 1280px;
  height: 54px;
  position: relative;
}
.infomations .content .header h3{
  width: 100%;
  height: 38px;
  font-size: 36px;
  color: #110567;
  line-height: 38px;
}
.infomations .content .header .blues{
  display: inline-block;
  width: 151px;
  border-top: 3px solid #009ae9;
  margin-top: 7px;
}
.infomations .content .header .long{
  display: inline-block;
  width: 1040px;
  border-top: 1px solid #e8e8e8;
  position: absolute;
  bottom: 0;
}
.infomations .content .news-list{
  width: 1202px;
  height: auto;
}
.infomations .content .news-list ul li{
  width: 1202px;
  height: 172px;
  margin-top: 20px;
}
.infomations .content .news-list ul li .time{
  width: 120px;
  height: 120px;
  background-color: #e8e8e8;
  display: inline-block;
  position: relative;
  text-align: center;
  padding-top: 20px;
  box-sizing: border-box; 
}
.infomations .content .news-list ul li .time .day{
  font-size: 36px;
  color: #999;
}
.infomations .content .news-list ul li .time .month{
  font-size: 24px;
  color: #999;
}
.infomations .content .news-list ul li .details{
  display: inline-block;
  width: 1005px;
  height: auto;
  margin-left: 40px;
  vertical-align: top;
}
.infomations .content .news-list ul li h4{
  width: 100%;
  height: 28px;
  font-size: 24px;
  color: #000;
  display: inline-block;
}
.infomations .content .news-list ul li h4 a{
  width: 100%;
  height: 28px;
  font-size: 24px;
  color: #000;
  display: inline-block;
  text-decoration: none;
}
.infomations .content .news-list ul li p{
  width: 1005px;
  height: auto;
  font-size: 16px;
  color: #999;
  line-height: 24px;
  margin-top: 20px;
}
.infomations .content .news-list ul li>span{
  display: inline-block;
  width: 1200px;
  height: 0;
  border-bottom: 1px solid #e8e8e8;
  margin-top: 20px;
}
.infomations .content .block{
  width: 100%;
  height: auto;
}
.infomations .content .block a{
  width: 100%;
  height: 28px;
  display: inline-block;
}
.infomations .content .block .el-pagination{
  text-align: center;
  height: auto;
}
</style>
<style>
.infomations .content .block .el-pagination.is-background .btn-next, .el-pagination.is-background .btn-prev, .el-pagination.is-background .el-pager li{
  min-width: 50px;
}
</style>
